package com.av.bcacc.javaapi.thread.productor;

public class Cooker extends Thread {
    @Override
    public void run() {
        while (true) {
            synchronized (Desk.objLock) {
                if (!Desk.HAS_FLAG) {
                    try {
                        System.out.println(Thread.currentThread().getName() + "###开始生产...");
                        Thread.sleep(1000);
                        System.out.println(Thread.currentThread().getName() + "###生产完毕了,通知吃货开吃...");
                        Desk.HAS_FLAG = true;
                        Desk.objLock.notifyAll();
                        Desk.objLock.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }

        }
    }
}
